#include "cc_log.h"
#include "cc_core.h"
#include "cc_mempool.h"

#if (CC_CONFIG_TEST_TIMER == 1)
int cnt = 0;
struct student
{
  int age;
  int num;
};

void timer_cb(void* data)
{
  struct student* stu = (struct student*)cc_timer_get_data(data);

  cc_log("this is timer %d data:%d %d\r\n", cc_timer_get_systick(), stu->age, stu->num);
}
cc_timer_t tim;

void t1_tim(void* temp)
{
  struct student stu = { 20, 200 };
  tim = cc_timer_create_and_start(timer_cb, cc_timer_auto_reload, 500, &stu);

  while (1)
  {
    cnt++;
    if (cnt == 30)
    {
      cc_log("stop\r\n");
      cc_timer_stop(tim);
    }
    if (cnt == 50)
    {
      cc_log("change time\r\n");
      cc_timer_change_time_and_start(tim, 1000);
    }

    if (cnt == 80)
    {
      cc_log("change mode\r\n");
      cc_timer_set_mode(tim, cc_timer_one_shot);
    }
    cc_delay(100);
  }
}
CC_THREAD_REGISTER(t1_tim, 10, 2048);
#endif
